package com.wenfs.demo.controller;

import com.wenfs.demo.entity.SysMenu;
import com.wenfs.demo.service.ISysMenu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author wenfs
 */
@Controller
@RequestMapping("menu")
public class MenuController {
  @Autowired
  private ISysMenu iSysMenm;

  @GetMapping("/findAll/{param}")
  public String findAll(Model model, @PathVariable("param")String param) {
    model.addAttribute("menus",iSysMenm.findAll());
    return param;
  }


  @PostMapping("/save")
  public String save(SysMenu menu) {
    iSysMenm.save(menu);
    return "menuSave";
  }

  @GetMapping("/setStatus")
  public String setStatus(Integer status,String menuCode) {
    iSysMenm.setStatus(status,menuCode);
    return "redirect:/menu/findAll/menuList";
  }


}
